package com.yskj.otms.services.impl;

import com.yskj.otms.controller.AiFeedbackController;
import com.yskj.otms.dao.IAiFeedbackDao;
import com.yskj.otms.dto.AiFeedbackDto;
import com.yskj.otms.dto.ParamDto;
import com.yskj.otms.services.IAiFeedbackServices;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by Administrator on 2019/1/9.
 */
@Service
public class AiFeedbackServicesImpl implements IAiFeedbackServices {
    private Logger logger = LoggerFactory.getLogger(AiFeedbackServicesImpl.class);
    @Autowired
    private IAiFeedbackDao iAiFeedbackDao;
    @Override
    public JSONObject selectAiFeedbackInfo(HttpServletRequest request) throws Exception {
        logger.info("AiFeedbackServicesImpl selectAiFeedbackInfo start");
        JSONObject jsonObject = new JSONObject();
        ParamDto paramDto = new ParamDto();
        paramDto.setPhoneNum((String) request.getSession().getAttribute("SESSION_PHONE_NUM"));
        List<AiFeedbackDto> aiFeedbackDtos = iAiFeedbackDao.selectAiFeedbackInfoByPhoneNum(paramDto);
        if (aiFeedbackDtos.size()==0 || aiFeedbackDtos == null){
            jsonObject.put("SUCCESS",false);
            jsonObject.put("MSG","抱歉！您没有货源信息！");
        }else{
            jsonObject.put("SUCCESS",true);
            jsonObject.put("aiFeedbackDtos",aiFeedbackDtos);
        }
        return jsonObject;
    }
}
